﻿using System;
using Microsoft.Xna.Framework.Graphics;

namespace FITClub.Util
{
    internal class RelativeCoordinatesToPixels
    {
        double relativeCoordinateTrasformation_X, relativeCoordinateTrasformation_Y;
        double posX, posY;

        public RelativeCoordinatesToPixels(double width, double height, Viewport vp)
        {
            posX = 0.0;
            posY = height;
            relativeCoordinateTrasformation_X = vp.Width / width;
            relativeCoordinateTrasformation_Y = vp.Height / height;
        }

        public int TransformX(double x)
        {
            return (int)Math.Round((posX + x) * relativeCoordinateTrasformation_X);
        }

        public int TransformY(double y)
        {
            return (int)Math.Round((posY - y) * relativeCoordinateTrasformation_Y);
        }

        public int TransformWidth(double w)
        {
            return (int)Math.Round(w * relativeCoordinateTrasformation_X);
        }

        public int TransformHeight(double h)
        {
            return (int)Math.Round(h * relativeCoordinateTrasformation_Y);
        }
    }
}